<template>
  <Common :sidebarItems="sidebarItems" :isHome="isHome">
    <component v-if="$frontmatter.home" :is="homeCom" />
    <Page v-else :sidebar-items="sidebarItems" />
    <Footer v-if="$frontmatter.home" class="footer" />
</Common>
</template>

<script>
import Home from '@theme/components/Home'
import HomeBlog from '@theme/components/HomeBlog'
import Page from '@theme/components/Page'
import Footer from '@theme/components/Footer'
import Common from '@theme/components/Common'
import { resolveSidebarItems } from '@theme/helpers/utils'

export default {
  components: { HomeBlog, Home, Page, Common, Footer },
  computed: {
    sidebarItems() {
      return resolveSidebarItems(
        this.$page,//页面对象
        this.$page.regularPath,//页面路径
        this.$site,//站点对象
        this.$localePath//语言路径
      )
    },
    isHome() {
      return this.$frontmatter.home
    },
    homeCom() {
      const { type } = this.$themeConfig
      if (type !== undefined) {
        return type == 'blog' ? 'HomeBlog' : type
      }
      return 'Home'
    }
  }
}
</script>

<style src="../styles/theme.styl" lang="stylus"></style>
